
import sys
import pygame

'''游戏开始界面'''
def showStartGameInterface(screen, cfg):
    #显示文本信息设置
    font_big = pygame.font.Font(cfg.FONT_PATH, 125)
    font_small = pygame.font.Font(cfg.FONT_PATH, 40)
    text_title = font_big.render(f"终结の谷", True, (255, 255, 0))
    text_title_rect = text_title.get_rect()
    text_title_rect.centerx = screen.get_rect().centerx
    text_title_rect.centery = screen.get_rect().centery - 125

    text_tip = font_small.render(f"按        开始游戏", True,(255, 215, 0))
    text_tip_rect = text_tip.get_rect()
    text_tip_rect.centerx = screen.get_rect().centerx 
    text_tip_rect.centery = screen.get_rect().centery + 40
    
    text_space = font_small.render(f"空格",True, (255, 215, 0))
    text_space_rect = text_space.get_rect()
    text_space_rect.centerx = screen.get_rect().centerx - 57
    text_space_rect.centery = screen.get_rect().centery + 40
    text_space_count = 0
    text_space_freq = 10
    text_space_show_flag = True

    text_tip2 = font_small.render(f"按    退出游戏", True, (255, 215, 0))
    text_tip2_rect = text_tip2.get_rect()
    text_tip2_rect.centerx = screen.get_rect().centerx 
    text_tip2_rect.centery = screen.get_rect().centery + 110

    text_quit = font_small.render(f"Q", True, (255, 215, 0))
    text_quit_rect = text_quit.get_rect()
    text_quit_rect.centerx = screen.get_rect().centerx - 58
    text_quit_rect.centery = screen.get_rect().centery + 110
    text_quit_count = 0
    text_quit_freq = 10
    text_quit_show_flag = True

    #界面主循环
    clock = pygame.time.Clock()
    while True:
        screen.fill((173,216,230))
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_SPACE:
                    return False
                elif event.key == pygame.K_q:
                    pygame.quit()
                    sys.exit()
        screen.blit(text_title, text_title_rect)
        screen.blit(text_tip, text_tip_rect)
        screen.blit(text_tip2, text_tip2_rect)
        if text_space_show_flag:
            screen.blit(text_space, text_space_rect)
        text_space_count += 1
        if text_space_count % text_space_freq == 0:
            text_space_count = 0
            text_space_show_flag = not text_space_show_flag
        if text_quit_show_flag:
            screen.blit(text_quit, text_quit_rect)
        text_quit_count += 1
        if text_quit_count % text_quit_freq == 0:
            text_quit_count = 0
            text_quit_show_flag = not text_quit_show_flag
        pygame.display.flip()
        clock.tick(cfg.FPS)
            
                

        
    


    
    
